
library(igraph)

########################################################
# get.giant.component(g)
#
# This function extracts the largest (weak) component from the network
# and returns it as an igraph object.
#
# Arguments:
#     g            igraph network
#
#####################################################
get.giant.component <- function(g) {

  if (!is.igraph(g)) stop("g is not an igraph object")

  comps <- clusters(g, mode="weak")
  induced.subgraph(g, which(which.max(comps$csize)==comps$membership))
}

